﻿using System.Linq;
using LightReader.Data;
using LightReader.Business.Services.Contracts;

using LightReader.Business.Entities;

namespace LightReader.Business.Services
{
    public class UserService : IUserService
    {
        private IUserDataAccess _userDataAccess;
        public UserService() {
            _userDataAccess = new UserDataAccess();
        }

        public UserService(IUserDataAccess userDataAccess)
        {
            _userDataAccess = userDataAccess;
        }

        public bool DoesUserExist(string username)
        {
            return _userDataAccess.DoesUserExist(username);
        }

        public User LoginUser(string username, string password)
        {
            return _userDataAccess.GetUser(username, password);
        }

        public User AddUser(string username, string password, string emailAddress)
        {
            return _userDataAccess.AddUser(username, password, emailAddress);
        }

        public bool SubscribeToFeed(User user, string feedTitle, string feedUrl)
        {
            return _userDataAccess.AddFeed(user.Id, feedTitle, feedUrl);
        }
    }
}
